<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var fun = function (arr) {
        arr.sort(function (a, b) {
            return a - b
        })
        var arr2 = []
        for (var i = arr[0]; i < arr[arr.length - 1]; i++) {
            arr2.push(i)
        }
        var arr3 = arr2.reduce(function (pre, cur) {
            return (arr.indexOf(cur) === -1 ? pre.concat(cur) : pre)
        }, [])
        // return arr3
        console.log(arr3)
    }([1, 6, 8, 22])
</script>

</html>